import SplashScene from "../SplashScene";
import GameDB, { Poker } from "./GameDB";
import GameEvent from "./GameEvent";
import GameView from "./GameView";



//裁判，隶属于GameScene,牌局管理者，准备好扑克牌，桌子等等
export default class GameCtrl{
    private m_GameDB: GameDB = null;
    private m_GameView: GameView = null;


    public Init(gameView:GameView,){
        this.m_GameView = gameView;
        
        SplashScene.eventTarget.on(GameEvent.INIT_POKER,this.m_GameView.OnEventInit,this.m_GameView)
        SplashScene.eventTarget.on(GameEvent.PLAY,this.m_GameView.OnEventPlay,this.m_GameView)
        SplashScene.eventTarget.on(GameEvent.INIT_GROUP_CARD,this.m_GameView.OnEventINitGroupCard,this.m_GameView)
        this.m_GameView.on(GameEvent.CLICK_POKER,this.m_GameDB.OnEventClickPoker,this.m_GameDB);
        
        this.m_GameDB = GameDB.Create();

    }

    public Play(){
        //移动所有牌到发牌区
        this.m_GameDB.Play();   

    }
    public Exit(){
        SplashScene.eventTarget.off(GameEvent.INIT_POKER,this.m_GameView.OnEventInit)
        SplashScene.eventTarget.off(GameEvent.PLAY,this.m_GameView.OnEventPlay,)
        SplashScene.eventTarget.off(GameEvent.INIT_GROUP_CARD,this.m_GameView.OnEventINitGroupCard)
        this.m_GameView.off(GameEvent.INIT_GROUP_CARD,this.m_GameView.OnEventINitGroupCard)
        // SplashScene.eventTarget.off(GameEvent.CLICK_POKER,this.m_GameDB.OnEventClickPoker);
        
    }

}
// export class PokerGroup{
//     public pokers: Poker[] = [];
// }